<template>
  <div>
    <kendoForm
      :kendo-form-items="kendoFormItems"
      :kendo-form="kendoForm"
      :kendo-params-value="kendoParamsValue"
    />
  </div>
</template>

<script>
  import kendoForm from '@/Views/components/kendo-vue-component/kendoForm/index.vue'
  import { isBlank } from '@/Utils/strUtil.js'
  export default {
    name: 'FileAddCmpt',
    components: {
      kendoForm
    },
    data() {
      return {
        dialogName: this.$attrs.data.dialogName,
        kendoFormItems: [
          {
            name: 'relBusiNo',
            label: '关联业务编号',
            paramName: 'relBusiNo',
            required: true,
            controlType: 'multicolumncombobox',
            // change: this.devInChargeChange,
            dataSource: 'PrjReqTaskDataSource',
            dataType: 'json',
            transportReadUrl: '/service/prjMng/reqmntTaskMng/findReqMntTaskList',
            dataMapping: {
              label: 'reqName',
              value: 'reqNo'
            },
            schema: {
              data: function(response) {
                if (typeof response.data === 'object') {
                  if (JSON.stringify(response.data) === '{}') {
                    return []
                  }
                }
                return response.data
              }
            },
            column: [
              {
                field: 'reqNo',
                title: '需求编号',
                width: 180
              },
              {
                field: 'reqName',
                title: '需求名称',
                width: 320
              }
            ]
          },
          {
            ref: 'REL_BUSI_TYPE_CD',
            remoteData: true,
            cascade: true,
            name: 'relBusiType',
            label: '关联业务类型',
            paramName: 'relBusiType',
            optionLabel: '--请选择--',
            controlType: 'dropDownList',
            filter: 'contains',
            dataType: 'json',
            transportReadUrl: '/service/sysMng/dict/findDictByTypeWithForm',
            required: true,
            autoBind: true,
            schema: {
              data: function(response) {
                return response.data
              }
            },
            dataMapping: {
              label: 'dictValNm',
              value: 'dictVal'
            },
            parameterMap: function(options, operation) {
              if (operation !== 'read' && options.models) {
                // eslint-disable-next-line no-undef
                return { models: kendo.stringify(options.models) }
              } else {
                // eslint-disable-next-line no-undef
                return kendo.stringify({ dict: 'REL_BUSI_TYPE_CD' })
              }
            }
          },
          {
            name: 'relFileDirName',
            label: '所属文件夹名称',
            paramName: 'relFileDirName',
            required: true,
            controlType: 'input'
          },
          {
            label: '文件上传',
            ref: 'materialUpload',
            genre: 'special',
            controlType: 'upload',
            paramName: 'files',
            required: true,
            multiple: true,
            asyncSaveUrl: '/service/decoration/commonUploadFiles',
            asyncRemoveUrl: '/service/decoration/commonRemoveFiles'
          }
        ],
        kendoForm: {
          ref: 'prodForm',
          valid: 'valid'
        },
        kendoParamsValue: {
          id: '',
          relBusiNo: '',
          relFileDirNo: '',
          relFileDirName: '',
          files: [],
          relBusiType: '',
          fileStoragePath: ''
        }
      }
    },
    mounted() {
      // 判断是否在根目录上创建文件或者文件夹
      const params = this.$attrs.data.param
      if (params && !isBlank(params.code)) {
        this.kendoParamsValue.relFileDirName = params.name
        this.kendoParamsValue.relFileDirNo = params.code
        this.kendoParamsValue.fileStoragePath = params.dirHierName
      }
    },
    methods: {
      onClick() {
        console.log(this.kendoParamsValue)
      }
    }
  }
</script>

<style>

</style>
